package com.wujie.hello.spring.cloud.alibaba.nacos.rest.consumer;

import com.wujie.hello.spring.cloud.alibaba.nacos.rest.consumer.config.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

import java.util.Collections;

@SpringBootApplication
@EnableDiscoveryClient
public class HelloSpringCloudAlibabaNacosRestConsumerApplication {
    @Autowired
    private TokenInterceptor tokenInterceptor;
    public static void main(String[] args) {
        SpringApplication.run(HelloSpringCloudAlibabaNacosRestConsumerApplication.class, args);
    }

    @Bean
    public RestTemplate restTemplate()
    {
        RestTemplate restTemplate = new RestTemplate();
        restTemplate.setInterceptors(Collections.singletonList(tokenInterceptor));
        return restTemplate;
    }

}
